package com.taiyuan.zfmvp.JUC.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @param
 * @Author: zhoufang@si-tech.com.cn
 * @Descriiption: callable和runable比较
 * @Date 2022/10/6
 * @return
 */

class mythread implements  Runnable{

    @Override
    public void run() {

    }
}

class mythread2 implements Callable{

    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        return 10;
    }
}

public class Demo1 {
    public static void main(String[] args) throws  Exception {

        new Thread(new mythread(),"aa").start();


        FutureTask<Integer> futureTask = new FutureTask<>(new mythread2());

        new Thread(futureTask,"test").start();
        while (!futureTask.isDone()){
            System.out.println("wait");

        }
        System.out.println(futureTask.get());
        System.out.println(Thread.currentThread().getName()+"----over");
    }
}
